package com.ln.第二遍1105.demo03;

import java.util.Arrays;
import java.util.Optional;

/**
 * @author Ln
 * @version 终极版
 * @date 2022/11/6 15:51
 */
public class Test01 {
    public static void main(String[] args) {
        Integer [] arr={1,2,3,4,5,6};

        // reduce规约操作
        Optional<Integer> reduce = Arrays.stream(arr).reduce((t1, t2) -> t1 += t2);
        System.out.println(reduce.get());

        Integer reduce1 = Arrays.stream(arr).reduce(0, Integer::max);
        System.out.println(reduce1);

        Integer reduce2 = Arrays.stream(arr).reduce(0, Integer::min);
        System.out.println(reduce2);

        Integer reduce3 = Arrays.stream(arr).reduce(0, Integer::sum);
        System.out.println(reduce3);
    }
}
